package joney.model;

public class Expense implements Comparable<Expense> {

	public static final String TRANSFER= "Transfer";
	
	private String type, name, note;
	private Account associatedAccount = null;
	private double amount;
	private long date;

	public Expense(long date, String type, String name, String note, double amount) {
		super();
		this.type = type;
		this.name = name;
		this.note = note;
		this.amount = amount;
		this.date = date;
	}
	
	
	
	
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		long temp;
		temp = Double.doubleToLongBits(amount);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		result = prime * result + (int) (date ^ (date >>> 32));
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + ((note == null) ? 0 : note.hashCode());
		result = prime * result + ((type == null) ? 0 : type.hashCode());
		return result;
	}




	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Expense other = (Expense) obj;
		if (Double.doubleToLongBits(amount) != Double
				.doubleToLongBits(other.amount))
			return false;
		if (date != other.date)
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (note == null) {
			if (other.note != null)
				return false;
		} else if (!note.equals(other.note))
			return false;
		if (type == null) {
			if (other.type != null)
				return false;
		} else if (!type.equals(other.type))
			return false;
		return true;
	}




	public Account getAssociatedAccount() {
		return associatedAccount;
	}

	public void setAssociatedAccount(Account associatedAccount) {
		this.associatedAccount = associatedAccount;
	}
	
	public long getDate() {
		return date;
	}


	public void setDate(long date) {
		this.date = date;
	}
	
	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getNote() {
		return note;
	}

	public void setNote(String note) {
		this.note = note;
	}

	public double getAmount() {
		return amount;
	}

	public void setAmount(double amount) {
		this.amount = amount;
	}

	public int compareTo(Expense o) {
		return new Long(date).compareTo(new Long(o.date));
	}
	

}
